package ISOFT2.Pr03.Presentacion;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JLabel;
import javax.swing.SwingConstants;

import ISOFT2.Pr03.Dominio.Cliente;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class VentanaMenu extends JFrame {

	private JPanel contentPane;
	private JButton btnVerHorarios;
	private JButton btnVerAsignaturas;
	private JButton btnVerAsistencia;
	private JButton btnNewButton;
	static VerAsistencia VA;
	static VerHorarios VH;
	static VerListaAsignaturas LA;
	private JLabel lblltimaConexin;
	private JLabel lblconexion;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VentanaMenu frame = new VentanaMenu();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public VentanaMenu() {
		addWindowListener(new ThisWindowListener());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		{
			btnVerHorarios = new JButton("Ver horarios");
			btnVerHorarios.setBounds(150, 56, 150, 23);
			btnVerHorarios.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					 VH = new VerHorarios();
					 VentanaLogin.menu.dispose();
				}
			});
			contentPane.add(btnVerHorarios);
		}
		{
			btnVerAsignaturas = new JButton("Ver asignaturas");
			btnVerAsignaturas.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					LA=new VerListaAsignaturas();
					VentanaLogin.menu.dispose();
				}
			});
			btnVerAsignaturas.setBounds(150, 90, 150, 23);
			contentPane.add(btnVerAsignaturas);
		}
		{
			btnVerAsistencia = new JButton("Ver asistencia");
			btnVerAsistencia.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					 VA=new VerAsistencia();
					VentanaLogin.menu.dispose();
				}
			});
			btnVerAsistencia.setBounds(150, 124, 150, 23);
			contentPane.add(btnVerAsistencia);
		}
		{
			btnNewButton = new JButton("Salir");
			btnNewButton.addActionListener(new BtnNewButtonActionListener());
			
			btnNewButton.setBounds(150, 228, 150, 23);
			contentPane.add(btnNewButton);
		}
		{
			lblltimaConexin = new JLabel("Última Conexión");
			lblltimaConexin.setHorizontalAlignment(SwingConstants.CENTER);
			lblltimaConexin.setBounds(10, 11, 99, 23);
			contentPane.add(lblltimaConexin);
		}
		{
			lblconexion = new JLabel("");
			lblconexion.setBounds(117, 15, 307, 14);
			contentPane.add(lblconexion);
			Cliente c=new Cliente();
			lblconexion.setText(c.ultima());
			
		}
	}
	
	private void Misalir() {
		Cliente c=new Cliente();
		c.guardarconexion();
		System.exit(0);
		
	}


	private class ThisWindowListener extends WindowAdapter {	
		public void windowClosing(WindowEvent arg0) {
			Misalir();
		}
	}
	private class BtnNewButtonActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			Misalir();
		}
	}
}
